"""
内容:将分享封装成一个类

"""
#引入
from ECshop.common.base import create_browser,Base,create_browser_op
import time


class PageShare01(Base):

    #属性
    url = 'http://localhost:8080/ecshop/user.php'
    first = ('link text', '首页')
    sport_camera = ('xpath', ("//img[@src='images/201605/thumb_img/64_thumb_G_1462952811633.jpg']"))
    share_goods=('xpath', ("//img[@src='themes/default/images/bnt_recommend.gif']"))
    copy_path=("xpath",("//textarea[@id='txt5_txt']"))
    new_web='https://baidu.com'
    #方法
    #打开网页
    def page_share_web(self):
        self.base_open_web(self.url)
    #点击首页
    def page_share_first(self):
        self.base_click(self.first)
    #点击运动相机
    def page_share_sport_camera(self):
        self.base_click(self.sport_camera)
    #点击分享
    def page_share_goods(self):
        self.base_click(self.share_goods)

    #点击复制链接
    def page_share_copy_path(self):
        result=self.base_get_text(self.copy_path)
        return result

    #关闭网页
    def page_share_quit(self):
        self.base_quit()

if __name__ == '__main__':
    s1=PageShare01(create_browser_op(r'C:\Users\lenovo\AppData\Local\Google\Chrome\User Data'))
    #打开网页
    s1.page_share_web()
    #点击首页
    s1.page_share_first()
    #点击运动相机
    s1.page_share_sport_camera()
    #点击分享
    s1.page_share_goods()
    time.sleep(5)
    #复制链接
    result=s1.page_share_copy_path()
    result1=result.split('\n')
    print(result1[1])

    #关闭
    s1.page_share_quit()

